<template>


  <div class="rateContainer">

         <div class="crumbs">
            <el-breadcrumb separator="/">
                <el-breadcrumb-item>
                  <span class="container-title-p">
                    运营管理
                    <i class="iconfont icon-jiantou"></i>
                  </span>
                  <span>系统设置</span>
                  </el-breadcrumb-item>
            </el-breadcrumb>
   </div>


  <el-tabs type="border-card">
    <el-tab-pane label="转出额度设置" class="card-container">
      <el-form>
        <el-form-item label="每天用户转出虚拟币最大数量：">
          <el-input style='width: 300px;' v-model='params.maxTransferOut' placeholder="单行输入" ></el-input>
        </el-form-item>
        <!-- <el-form-item label="手续费-单笔按比">
          <el-input style='width: 300px;' v-model='params.singleFeeRatio' placeholder="手续费-单笔按比" ></el-input>
        </el-form-item>
        <el-form-item label="手续费-单笔固定">
          <el-input style='width: 300px;' v-model='params.singleFixedFee' placeholder="手续费-单笔固定" ></el-input>
        </el-form-item> -->
        <el-form-item label="每天用户单笔转出虚拟币最大数量：">
          <el-input style='width: 300px;' v-model='params.singleTransferOut' placeholder="单行输入" ></el-input>
        </el-form-item>
      </el-form>
    <div><el-button type="success" @click='onSubmit' style="margin:20px 0;">保存</el-button></div>
    </el-tab-pane>
    <el-tab-pane label="手续费设置" class="card-container">
      <el-form style='display: inline-block;width:600px;' label-width="180px" align='left'>
        <el-form-item label='币种：'>
          <el-select placeholder="请选择币种" v-model="type">
            <el-option v-for="(item,index) of Virtualcurrency" :key='index'
            :label="item.virtualCurrencyCode=='BTC'?'比特币':item.virtualCurrencyCode=='ETH'?'以太坊':'华克金'"
            :value="item.virtualCurrencyId"
            ></el-option>
          </el-select>
        </el-form-item>
        <!-- 如果是比特币 -->
        <div v-if='type==1'>
          <el-form-item label='比例手续费-币币交易：'>
            <el-input placeholder="请输入手续费(比特币)" style='width:200px;' v-model='params.transfers[0].bbTransactionRatio'></el-input>
          </el-form-item>
          <el-form-item label='比例手续费-购买：'>
            <el-input placeholder="请输入手续费(比特币)" style='width:200px;' v-model='params.transfers[0].buyRatio'></el-input>
          </el-form-item>
          <el-form-item label='比例手续费-提现：'>
            <el-input placeholder="请输入手续费(比特币)" style='width:200px;' v-model='params.transfers[0].withdrawalRatio'></el-input>
          </el-form-item>
          <el-form-item label='固定手续费-外部转入：'>
            <el-input placeholder="请输入手续费(比特币)" style='width:200px;' v-model='params.transfers[0].externalInFee'></el-input>
          </el-form-item>
          <el-form-item label='固定手续费-转出外部：'>
            <el-input placeholder="请输入手续费(比特币)" style='width:200px;' v-model='params.transfers[0].externalOutFee'></el-input>
          </el-form-item>
          <el-form-item label='固定手续费-转出内部：'>
            <el-input placeholder="请输入手续费(比特币)" style='width:200px;' v-model='params.transfers[0].internalOutFee'></el-input>
          </el-form-item>
        </div>
        <!-- ETH -->
        <div v-if='type==2'>
          <el-form-item label='比例手续费-币币交易：'>
            <el-input placeholder="请输入手续费(以太坊)" style='width:200px;' v-model='params.transfers[1].bbTransactionRatio'></el-input>
          </el-form-item>
          <el-form-item label='比例手续费-购买：'>
            <el-input placeholder="请输入手续费(以太坊)" style='width:200px;' v-model='params.transfers[1].buyRatio'></el-input>
          </el-form-item>
          <el-form-item label='比例手续费-提现：'>
            <el-input placeholder="请输入手续费(以太坊)" style='width:200px;' v-model='params.transfers[1].withdrawalRatio'></el-input>
          </el-form-item>
          <el-form-item label='固定手续费-外部转入：'>
            <el-input placeholder="请输入手续费(以太坊)" style='width:200px;' v-model='params.transfers[1].externalInFee'></el-input>
          </el-form-item>
          <el-form-item label='固定手续费-转出外部：'>
            <el-input placeholder="请输入手续费(以太坊)" style='width:200px;' v-model='params.transfers[1].externalOutFee'></el-input>
          </el-form-item>
          <el-form-item label='固定手续费-转出内部：'>
            <el-input placeholder="请输入手续费(以太坊)" style='width:200px;' v-model='params.transfers[1].internalOutFee'></el-input>
          </el-form-item>
        </div>
        <!-- 华克金 -->
        <div v-if='type==3'>
          <el-form-item label='比例手续费-币币交易：'>
            <el-input placeholder="请输入手续费(华克金)" style='width:200px;' v-model='params.transfers[2].bbTransactionRatio'></el-input>
          </el-form-item>
          <el-form-item label='比例手续费-购买：'>
            <el-input placeholder="请输入手续费(华克金)" style='width:200px;' v-model='params.transfers[2].buyRatio'></el-input>
          </el-form-item>
          <el-form-item label='比例手续费-提现：'>
            <el-input placeholder="请输入手续费(华克金)" style='width:200px;' v-model='params.transfers[2].withdrawalRatio'></el-input>
          </el-form-item>
          <el-form-item label='固定手续费-外部转入：'>
            <el-input placeholder="请输入手续费(华克金)" style='width:200px;' v-model='params.transfers[2].externalInFee'></el-input>
          </el-form-item>
          <el-form-item label='固定手续费-转出外部：'>
            <el-input placeholder="请输入手续费(华克金)" style='width:200px;' v-model='params.transfers[2].externalOutFee'></el-input>
          </el-form-item>
          <el-form-item label='固定手续费-转出内部：'>
            <el-input placeholder="请输入手续费(华克金)" style='width:200px;' v-model='params.transfers[2].internalOutFee'></el-input>
          </el-form-item>
        </div>
        <el-form-item>
          <el-button type='success' @click='saveTransfers'>保存</el-button>
        </el-form-item>
      </el-form>
      <div class='tipsLog'>
        <p>手续费A解析：为用户平台转给非用户平台，固定值。</p>
        <p>手续费B解析：为用户平台转给用户平台，固定值。</p>
        <p>购买、取现是按照比例来算的手续费，每个币都要设置参数。</p>
      </div>
    </el-tab-pane>
    <el-tab-pane label="归档设置" class="card-container">
      <div class='settings'>
        <p class='setTitle'>归档操作：</p>
        <p><el-button type='primary' size="small">开始归档</el-button></p>
      </div>
       <div class='settings money'>
        <p class='setTitle'>平台账户数量：</p>
        <!-- <p><el-button type='primary' size="small">开始归档</el-button></p> -->
        <p>比特币：{{btc}}</p>
        <p>以太坊：{{eth}}</p>
        <p>华克金：{{wcg}}</p>
        <el-button type='primary' @click='getMoney'>获取最新数据</el-button>
      </div>
      <div class='settings money'>
        <p class='setTitle'>归档旷工费设置：</p>
        <p>以太坊：<el-input placeholder="请输入" style='width: 200px;margin-right: 15px;' size='small'></el-input><el-button type='primary' size="small">保存</el-button></p>
        <p>华克金：<el-input placeholder="请输入" style='width: 200px;margin-right: 15px;' size='small'></el-input><el-button type='primary' size="small">保存</el-button></p>
      </div>
    </el-tab-pane>
  </el-tabs>
  <loading v-if="loading" :tip='tip'></loading>
  </div>
</template>


<style scoped>
.ratio-input{
    width:400px;
}
.setTitle{
  background: rgb(238,246,246);
  padding: 5px 8px;
  margin-bottom: 15px;
}
.card-container{
    /* padding-top:20px; */
}
.money{
  line-height: 35px;
  margin-top: 15px;
}
.tipsLog{
  display: inline-block;
  width: 400px;
  vertical-align: top;
  line-height: 35px;
}
.country-rate{
    width:300px;
    float: left;
    margin:10px;
}
</style>

<script>
import {api,apiGet} from "@/api/index";
import loading from '@/components/common/loading.vue';
export default {
  data() {
    return {
      tip:'',
      type:1,
      loading:false,
      params:{
        maxTransferOut :'',//虚拟币-每天总转出数量
        // singleFeeRatio :'',// 手续费-单笔按比
        // singleFixedFee :'',//手续费-单笔固定
        singleTransferOut :'',//虚拟币-单笔转出数量
        transfers: [
          {
            bbTransactionRatio :'',//比例手续费-BB交易 ,
            buyRatio :'',//比例手续费-购买 ,
            externalInRatio :'',//比例手续费-外部转入 ,
            externalOutFee :'',//固定手续费-外部转出 ,
            internalOutFee :'',//固定手续费-内部转出 ,
            withdrawalRatio :'',//比例手续费-提现
            virtualCurrencyCode: "BTC",//货币标识 ,
            virtualCurrencyId: 1,//货币标识 ,
          },
          {
            bbTransactionRatio :'',//比例手续费-BB交易 ,
            buyRatio :'',//比例手续费-购买 ,
            externalInRatio :'',//比例手续费-外部转入 ,
            externalOutFee :'',//固定手续费-外部转出 ,
            internalOutFee :'',//固定手续费-内部转出 ,
            withdrawalRatio :'',//比例手续费-提现
            virtualCurrencyCode: "ETH",
            virtualCurrencyId: 2
          },
          {
            bbTransactionRatio :'',//比例手续费-BB交易 ,
            buyRatio :'',//比例手续费-购买 ,
            externalInRatio :'',//比例手续费-外部转入 ,
            externalOutFee :'',//固定手续费-外部转出 ,
            internalOutFee :'',//固定手续费-内部转出 ,
            withdrawalRatio :'',//比例手续费-提现
            virtualCurrencyCode: "WCG",
            virtualCurrencyId: 3
          }
        ]
      },
      activeName: "second",
      select:"",
      btc:'',
      eth:'',
      wcg:'',
      btmSet:[
          {"id":1,"country":"美国","ckNum":100,"qkNum":300},
          {"id":1,"country":"英国","ckNum":100,"qkNum":300},
          {"id":1,"country":"加拿大","ckNum":100,"qkNum":300},
          {"id":1,"country":"马来西亚","ckNum":100,"qkNum":300}
      ],
      Virtualcurrency:[
        {
          virtualCurrencyId:1,
          virtualCurrencyCode:'BTC',
          fixedFeeA:'0.05',
          fixedFeeB:'0.05',
          singleFeeRatio:'0.005'
        },
        {
          virtualCurrencyId:2,
          virtualCurrencyCode:'ETH',
          fixedFeeA:'0.05',
          fixedFeeB:'0.05',
          singleFeeRatio:'0.005'
        },
        {
          virtualCurrencyId:3,
          virtualCurrencyCode:'WCG',
          fixedFeeA:'0.05',
          fixedFeeB:'0.05',
          singleFeeRatio:'0.005'
        }
      ]
    }
  },
  components:{
    loading
  },
  methods: {
    handleClick(tab, event) {
      // ////console.log(tab, event);
    },
    onSubmit(){
      this.loading=true;
      this.tip="提交设置";
      api.setting.setting(this.params).then(res=>{
        ////console.log(res);
        this.loading=false;
        this.$message.success('操作成功');
      })
    },
    getMoney(){
       this.loading=true;
       apiGet.account.platform({},true,'1').then(btc=>{
         this.btc=btc.amount;
       })
       apiGet.account.platform({},true,'2').then(eth=>{
         this.eth=eth.amount;
       })
       apiGet.account.platform({},true,'3').then(wcg=>{
         this.wcg=wcg.amount;
         this.loading=false;
       })
    },
    saveTransfers(){
      this.loading=true;
      this.tip="提交设置";
      api.setting.setting(this.params).then(res=>{
        ////console.log(res);
        this.loading=false;
        this.$message.success('操作成功');
      })
    },
    getSetting(){
      apiGet.setting.setting({}).then(res=>{
        ////console.log(res)
          this.params={
            maxTransferOut :res.maxTransferOut,//虚拟币-每天总转出数量
            // singleFeeRatio :res.singleFeeRatio,// 手续费-单笔按比
            // singleFixedFee :res.singleFixedFee,//手续费-单笔固定
            singleTransferOut :res.singleTransferOut,//虚拟币-单笔转出数量
            transfers: res.transfers
          }
      })
    },
  },
  mounted () {
    this.getSetting();
    this.getMoney();
    ////console.log(this.params)
  }
};
</script>

